// Package Controller /*
package Controller

import (
	"github.com/gin-gonic/gin"
	"github.com/syyongx/php2go"
	"projectFrame/app/Common/Utils"
	"projectFrame/app/Exception"
)

type BaseController struct {
}

func (receiver BaseController) JsonSuccess(message string, data map[string]interface{}) string {
	return Utils.JsonSuccess(message, data)
}

func (receiver BaseController) JsonError(message string, data map[string]interface{}) string {
	return Utils.JsonError(message, data)
}

func (receiver BaseController) Params(c *gin.Context) map[string]interface{} {

	params := make(map[string]interface{})

	for field, value := range Utils.GetQueryParams(c) {
		params[field] = value
	}

	for field, value := range Utils.GetPostFormParams(c) {
		params[field] = value
	}

	return params
}

func (receiver BaseController) FilterData(params map[string]interface{}, errorMessageMap map[string]string) map[string]interface{} {
	for checkField, nullMessage := range errorMessageMap {
		value, ok := params[checkField]

		if ok == false {
			Exception.ThrowNewCommonException(500, nullMessage, map[string]interface{}{
				"params":          params,
				"errorMessageMap": errorMessageMap,
			})
		}

		if php2go.Empty(value) {
			Exception.ThrowNewCommonException(500, nullMessage, map[string]interface{}{
				"params":          params,
				"errorMessageMap": errorMessageMap,
			})
		}
	}

	return params
}
